package livesun.justiceeternal.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.zzhoujay.markdown.MarkDown;
import com.zzhoujay.richtext.ImageHolder;
import com.zzhoujay.richtext.RichText;
import com.zzhoujay.richtext.RichTextConfig;
import com.zzhoujay.richtext.callback.ImageGetter;
import com.zzhoujay.richtext.callback.ImageLoadNotify;
import com.zzhoujay.richtext.callback.OnImageClickListener;
import com.zzhoujay.richtext.ig.DefaultImageDownloader;
import com.zzhoujay.richtext.ig.DefaultImageGetter;


import java.util.ArrayList;
import java.util.List;

import livesun.justiceeternal.R;
import livesun.justiceeternal.adapter.ItemsBean;
import livesun.justiceeternal.base.BaseActivity;
import livesun.justiceeternal.base.Contract;
import livesun.justiceeternal.utils.ImageUtils;
import livesun.justiceeternal.utils.ToastUtil;
import livesun.justiceeternal.utils.UiUtils;

/**
 * 类描述：
 * 创建人：livesun
 * 创建时间：2017/12/29.
 * 修改人：
 * 修改时间：
 * github：https://github.com/livesun
 */
public class MarkDownActivity extends BaseActivity {

    private String mHeadBody;
    private TextView mTextView;
    private RichText mRichText;

    @Override
    public int getResourcesId() {
        return R.layout.activity_markdown;
    }

    @Override
    public void initView() {
        mTextView = findView(R.id.webview);
       ImageView imageView= findView(R.id.test);
        String image = getIntent().getStringExtra("image");
        RichText into = RichText.fromMarkdown("哈哈")
                .into(mTextView);

        Drawable drawable = into.getDrawable(image);
        if(drawable!=null){
            imageView.setImageDrawable(drawable);
        }else{
            ToastUtil.showShort("空");
        }

       /* ItemsBean  itemsBean = (ItemsBean) getIntent().getSerializableExtra(Contract.ITEMBEAN);
        mHeadBody = itemsBean.getBody();
        //设置单线程 顺序执行
        mRichText = RichText.fromMarkdown(mHeadBody).bind(this).
                singleLoad(true).
                imageClick(new OnImageClickListener() {
                    @Override
                    public void imageClicked(List<String> imageUrls, int position) {
                        Intent intent = new Intent();
                        intent.putStringArrayListExtra("IMGES", (ArrayList<String>) imageUrls);
                        intent.putExtra("position", position);
                        intent.setClass(MarkDownActivity.this, PhotoActivity.class);
                        startActivity(intent);

                    }
                }).
                imageGetter(new DefaultImageGetter()).
                into(mTextView);*/

    }

    @Override
    public void initListener() {

    }

    @Override
    public void onClick(View v, int id) {

    }
}
